package 二叉树题目.点击消除;

import java.util.*;

public class Soulution {





    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            Deque<Character> queue = new LinkedList<>();
            List<Character> list = new ArrayList<>();
            queue.offer(s.charAt(0));
            int tmp = 0;
            for (int i = 1; i < s.length(); i++) {

                if (queue.isEmpty() || queue.peekLast() != s.charAt(i)) {
                    queue.offer(s.charAt(i));
                } else {
                    queue.pollLast();
                }
            }
            if (queue.isEmpty()) {
                System.out.println("0");
            } else {
                int size = queue.size();
                for (int j = 0; j < size; j++) {
                    System.out.print(queue.pollFirst());
                }
            }
        }
    }
}
